﻿using System;
using System.Windows.Forms;
using agsXMPP;

namespace Lapd.PoC
{
    public partial class LogOn : Form
    {
        private XmppClientConnection xmppClientConnection;

        public LogOn(XmppClientConnection xmppClientConnection)
        {
            InitializeComponent();

            this.DialogResult = DialogResult.Cancel;

            this.xmppClientConnection = xmppClientConnection;
        }

        private void mitLogin_Click(object sender, EventArgs e)
        {
            stbLogin.Text = "Conectando...";

            Jid jid = new Jid(txtUser.Text);

            xmppClientConnection.Password = txtPassword.Text;
            xmppClientConnection.Username = jid.User;
            xmppClientConnection.Server = jid.Server;
            xmppClientConnection.AutoResolveConnectServer = false;
            xmppClientConnection.ConnectServer = txtServer.Text;
            xmppClientConnection.UseStartTLS = false;

            this.DialogResult = DialogResult.OK;

            this.Close();
        }

        private void mitCancelar_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}